﻿@using HCMessage.Model
@{
    ViewBag.Title = "ItemDetail";
    var model = (ItemReport) Model;
}

<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $(function() {
            $('#myTab li:first').addClass("active");
            $('#divItemList div:first').addClass("active");
        });
        $('#myTab a').click(function (e) {
          var env = $(this).attr("data-env");
            $("#divItemList div").each(function() {
                $(this).removeClass("active");
                if ($(this).attr("data-env") == env) {
                    $(this).addClass("active");
                }
            });      
        });
    });
   
</script>
    <h2 class="page-header">Item List </h2>  
  
<ul class="nav nav-tabs"  id="myTab">
    @foreach (var r in model.EnvCtList)
    {
         <li ><a href="#" role="tab" data-toggle="tab" data-env="@r.EnvCode">@r.EnvCode</a></li>
    }
</ul>
<div class="tab-content" id="divItemList">
    @foreach (var r in model.EnvCtList)
    {
        var flag = 0;
        var itemList = model.ItemReportList.Where(x => x.EnvCd == r.EnvCode).ToList();
        if (itemList.Count > 0)
        {
             <div class="table-responsive tab-pane" data-env="@r.EnvCode" >
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Address</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in itemList)
                {
                     <tr>
                    <td>@item.Name</td>
                    <td>@item.Address</td>
                    <td><button type="button" class="btn btn-sm btn-primary">Update</button></td>
                </tr>
                }
               
            </tbody>
        </table>
    </div>
        }
    }
</div>
